<template>
    <ul class="catagtory">
    <li v-for="item in category" :key="item.id" :class="{select: item.id === currentCategory}" @click="$store.commit('category/updateCurrentCategory', item.id)">
        {{item.name}}
    </li>
  </ul>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  // 计算属性
  computed: {
    ...mapGetters(['category', 'currentCategory'])
  },
  // 实例创建完成
  created () {
    this.$store.dispatch('category/getCategory')
  }
}
</script>

<style>

</style>
